"""
执行此代码时，会将本目录下的部分文件复制到另一个目录下
"""

import os
import shutil

# 定义源目录和目标目录
source_dir = "./"
target_dir = "/Users/zeyilin/Desktop/Coding/hf_space/HivisionIDPhotos_hf"

# 定义要复制的文件或文件夹
files_to_copy = [
    "demo",
    "hivision",
]

# 遍历要复制的文件列表
for file in files_to_copy:
    # 构建源文件路径
    source_file = os.path.join(source_dir, file)
    # 构建目标文件路径
    target_file = os.path.join(target_dir, file)

    # Check if target is a file or directory
    if os.path.isfile(target_file):
        os.remove(target_file)
        print(f"删除文件: {target_file}")
    elif os.path.isdir(target_file):
        shutil.rmtree(target_file)
        print(f"删除文件夹: {target_file}")
    else:
        print(f"Skipping: {target_file} is neither a file nor a directory")

    # 复制文件，如果存在，就覆盖
    if os.path.isdir(source_file):
        shutil.copytree(source_file, target_file)
        print(f"复制文件夹: {source_file} -> {target_file}")
    else:
        shutil.copy2(source_file, target_file)
        print(f"复制文件: {source_file} -> {target_file}")
